package com.patterns.java.adapter;

/**
 * MP3声音播放
 * @author 三多
 * @Time 2021/10/14
 */
public class AudioPlayer implements MediaPlayer {
    MediaAdapter mediaAdapter;
    /**
     * 播放规范
     */
    @Override
    public void play(String audioType, String fileName) {
        //内置支持mp3
        if("mp3".equalsIgnoreCase(audioType)){
            System.out.println("Playing mp3 file. Name: "+fileName);
        }else if("vlc".equalsIgnoreCase(audioType)||"mp4".equalsIgnoreCase(audioType)){
            mediaAdapter = new MediaAdapter(audioType);
            mediaAdapter.play(audioType,fileName);
        }else{
            System.out.println("Invalid media. "+
                    audioType + " format not supported");
        }

    }
}
